<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>

<head>
    <title>云纵停车开放网关测试</title>
    <style type="text/css">
        table
        {border-collapse: collapse;margin: 0 auto;text-align:left;font-size:14px;font-family:微软雅黑;font-color:"black";}
        table td, table th
        {border: 1px solid #cad9ea;color: #666;height: 30px;}
        table thead th
        {background-color: #CCE8EB;width: 100px;}
        table tr:nth-child(odd)
        {background: #fff;}
        table tr:nth-child(even)
        {background: #F5FAFA;}
        input[type=text]
        {width: 600px;}
        input[type=button]
        {width: 100px;}
        input[type=submit]
        {width: 200px; height: 30px;}
    </style>
</head>

<body>
    <form action="http://localhost:8888/yz/parking/sendTradeJsPay" name="returnfunc" id= "returnfunc" method="post">
        <table width="90%" class="table">
            <caption>
                <h2>JSAPI支付测试</h2>
            </caption>
            <thead>
                <tr>
                    <th width="25%"><b>英文名称</b></th>
                    <th width="25%"><b>中文名称</b></th>
                    <th width="50%"><b>参数值</b></th>
                </tr>
            </thead>
            <tr>
                <td>api_name</td>
                <td>接口名称</td>
                <td><input type="text" name="api_name" id="api_name" value="yz.trade.jspay"/></td>
            </tr>
            <tr>
                <td>service_name</td>
                <td>机构号</td>
                <td><input type="text" name="service_name" id="service_name" value="1232131212132"/></td>
            </tr>
            <tr>
                <td>timestamp</td>
                <td>时间戳</td>
                <td>
                    <input type="text" name="timestamp" id="timestamp" value=""/>
                    &nbsp;&nbsp;&nbsp;&nbsp;
                    <input type="button" value="获取" onclick="getTimestampStr();"/>
                </td>
            </tr>
            <tr>
                <td>charset</td>
                <td>字符编码</td>
                <td><input type="text" name="charset" id="charset" value="UTF-8"/></td>
            </tr>
            <tr>
                <td>version</td>
                <td>版本编号</td>
                <td><input type="text" name="version" id="version" value="1.0"/></td>
            </tr>
            <tr>
                <td>sign_type</td>
                <td>签名类型</td>
                <td><input type="text" name="sign_type" id="sign_type" value="RSA"/></td>
            </tr>
            <tr>
                <td>app_auth_token</td>
                <td>授权token</td>
                <td><input type="text" name="app_auth_token" id="app_auth_token" value=""/></td>
            </tr>
            <tr>
                <td>pay_type</td>
                <td>支付类型</td>
                <td><input type="text" name="pay_type" id="pay_type" value="ALIPAY"/></td>
            </tr>
            <tr>
                <td>mch_id</td>
                <td>商户号</td>
                <td><input type="text" name="mch_id" id="mch_id" value="mch_id18000023123213123231"/></td>
            </tr>
            <tr>
                <td>sub_mchid</td>
                <td>子商户号</td>
                <td><input type="text" name="sub_mchid" id="sub_mchid" value="sub_mchid1800002312785875"/></td>
            </tr>
            <tr>
                <td>official_mchid</td>
                <td>官方商户号</td>
                <td><input type="text" name="official_mchid" id="official_mchid" value="pid123"/></td>
            </tr>
            <tr>
                <td>total_amount</td>
                <td>订单金额(分)</td>
                <td><input type="text" name="total_amount" id="total_amount" value="1"/></td>
            </tr>
            <tr>
                <td>out_trade_no</td>
                <td>商户订单号</td>
                <td><input type="text" name="out_trade_no" id="out_trade_no" value=""/>
                    &nbsp;&nbsp;&nbsp;&nbsp;
                    <input type="button" value="获取" onclick="getOutTradeNo();"/>
                </td>
            </tr>
            <tr>
                <td>subject</td>
                <td>订单详情</td>
                <td><input type="text" name="subject" id="subject" value="测试订单"/></td>
            </tr>
            <tr>
                <td>extend_params</td>
                <td>业务扩展参数</td>
                <td><input type="text" name="extend_params" id="extend_params" value="{&quot;parking_id&quot;:&quot;PI1509464128728884840&quot;,&quot;car_number&quot;:&quot;京XX1234&quot;,&quot;einlass&quot;:2019-08-15 17:30:26,&quot;parking_hours&quot;:1.5,&quot;parking_name&quot;:测试停车场}"/></td>
            </tr>
            <tr>
                <td>goods_detail</td>
                <td>商品详情</td>
                <td><input type="text" name="goods_detail" id="goods_detail" value="{&quot;goods_id&quot;:&quot;goods_id123&quot;,&quot;goods_name&quot;:&quot;停车缴费&quot;,&quot;quantity&quot;:1,&quot;price&quot;:1}"/></td>
            </tr>
            <tr>
                <td>goods_tag</td>
                <td>订单优惠标记</td>
                <td><input type="text" name="goods_tag" id="goods_tag" value=""/></td>
            </tr>
            <tr>
                <td>attach</td>
                <td>附加数据</td>
                <td><input type="text" name="attach" id="attach" value=""/></td>
            </tr>
            <tr>
                <td>notify_url</td>
                <td>异步通知地址</td>
                <td><input type="text" name="notify_url" id="notify_url" value=""/></td>
            </tr>
            <tr>
                <td>sign</td>
                <td>签名</td>
                <td>
                    <textarea rows="3" cols="50" id="sign" name="sign"></textarea>
                    &nbsp;&nbsp;&nbsp;&nbsp;
                    <input type="button"value="获取" onclick="getSign();"/>
                </td>
            </tr>
            <tr>
                <td width="100%" colspan="3" align="center">
                    <input type="hidden" id="pageType" name="pageType" value="tradeJsPay">
                    <input type="submit" value="提交"/>
                </td>
            </tr>
        </table>
    </form>

    <script src="https://code.jquery.com/jquery-3.1.1.min.js"></script>
    <script type="text/javascript">
        function getTimestampStr() {
            $.ajax({
                type : "GET",
                url : "http://localhost:8888/yz/parking/getTimestamp",
                dataType : "json", //预期服务器返回的数据
                success : function(data) {
                    $("#timestamp").val(data.timestampStr)
                },
            });
        }

        function getOutTradeNo() {
            $.ajax({
                type : "GET",
                url : "http://localhost:8888/yz/parking/getOutTradeNo",
                dataType : "json", //预期服务器返回的数据
                success : function(data) {
                    $("#out_trade_no").val(data.outTradeNoStr)
                },
            });
        }

        function getSign() {
            $.ajax({
                type : "GET",
                url : "http://localhost:8888/yz/parking/getSign",
                data : {
                    api_name : $("#api_name").val(),
                    service_name : $("#service_name").val(),
                    timestamp : $("#timestamp").val(),
                    charset : $("#charset").val(),
                    version : $("#version").val(),
                    sign : $("#sign").text(),
                    sign_type : $("#sign_type").val(),
                    app_auth_token : $("#app_auth_token").val(),
                    pay_type : $("#pay_type").val(),
                    mch_id : $("#mch_id").val(),
                    sub_mchid : $("#sub_mchid").val(),
                    official_mchid : $("#official_mchid").val(),
                    total_amount : $("#total_amount").val(),
                    out_trade_no : $("#out_trade_no").val(),
                    subject : $("#subject").val(),
                    extend_params : $("#extend_params").val(),
                    goods_detail : $("#goods_detail").val(),
                    goods_tag : $("#goods_tag").val(),
                    attach : $("#attach").val(),
                    notify_url : $("#notify_url").val(),
                    pageType : $("#pageType").val()
                },
                dataType : "json", //预期服务器返回的数据
                success : function(data) {
                    $("#sign").text(data.signStr)
                },
            });
        }
    </script>

</body>

</html>
